package com.flyduck.vueshop.order.h5.controller;

import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.redis.annotation.NoRepeatSubmit;
import com.flyduck.vueshop.common.sotoken.annotation.Login;
import com.flyduck.vueshop.order.h5.service.H5PayService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * <p>
 * AppPayController
 * </p>
 *
 * @author flyduck
 * @since 2024-05-22
 */
@RestController
@RequestMapping("/order/h5/pay")
public class H5PayController {

    @Resource
    private H5PayService h5PayService;

    @Login
    @NoRepeatSubmit(lockTime = 5)
    @PostMapping("/orderPayByOrderSn")
    public Result<String> orderPayByOrderSn(String orderSn){
        return Result.success(h5PayService.orderPayByOrderSn(orderSn));
    }

    @Login
    @PostMapping("/payCheckByOrderSn")
    public Result<String> payCheckByOrderSn(String orderSn){
        return Result.success(h5PayService.payCheckByOrderSn(orderSn));
    }

    @PostMapping("/payNotify")
    public void payNotify(@RequestParam Map<String,String> paramMap, HttpServletResponse response) throws IOException {
        h5PayService.payNotify(paramMap,response);
    }
}
